<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="wt.httpgw.URLFactory"%>
<%
String baseUrl = new URLFactory().getBaseHREF();
%>
<head>
<title>创建文档</title>
</head>
<body>


<center>
<div style="margin:10px 0;"></div>
	<div class="easyui-panel" title="创建文档" style="width:650px">
		<div style="padding:10px 0 10px 60px">
<form method="post" enctype="multipart/form-data" name="docForm1" id="docForm1">
  <table>
  	  <tr>
      <td>主要内容</td>
      <td>
        <input  type="file" id="inp_primary1" name="inp_primary1"  size="45" onchange="setName1()"/>
      </td>
    </tr>
    <tr>
      <td style="width:100px">*名称</td>
      <td>
        <input class="easyui-validatebox" data-options="required:true" name="docName1" id="docName1" type="text" size="45" />
      </td>
    </tr>
    <tr>
      <td >说明</td>
      <td>
        <textarea name="desc1" id="desc1" cols="45" rows="5"></textarea>
      </td>
    </tr>
    <tr>
      <td colspan="2">
            <br/>
          附件：<a href="javascript:void(0)" onclick="addAppendix1('appendixFileId1')">添加附件</a>
               </td>
    </tr>
     <tr>
                <td colspan="2">
                <div id="appendixFileId1"></div>
                </td>
				
            </tr>
    <tr>
      <td>&nbsp;</td>
      <td align="center"><label>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm1()">提交</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm1()">清除</a>
      </label></td>
    </tr>
  </table>
</form>
</div>
</div>
</center>
<script type="text/javascript">

	function setName1()
	{
		var value=document.getElementById("inp_primary1").value;
		var docValue=value.substring(value.lastIndexOf("\\")+1,value.lastIndexOf(".")); 
		document.getElementById("docName1").value=docValue;
	}
	function submitForm1(){
	 var docName=document.getElementById("docName1").value;
	 if(docName==""||docName==null)
	 {
		 alert("名称不能为空");
		 return;
	}
		
	$('#docForm1').submit()
	}
	function clearForm1(){
	$('#docForm1').form('clear');
	}
	/*添加附件功能*/
	function addAppendix1(htmlId){
		//alert("appendixFileId :"+htmlId);
		var $div = $("#"+htmlId);
		var len = $div.children("input[type='file']") + 1;
		//alert("len :"+len);
		$div.append("<div><input type='file' size=60 name='appendixFile_"+len+"' /><input type='button' value='-' onclick='removeAppendix1(this)'></input></div>");
	}
	function removeAppendix1(obj){
		var temp = $(obj);
		temp.parent("div").remove(); 
	}
	
	function initCreateQues1(){
		$("#docForm1").form({
			url:'<%=baseUrl%>shmged/jsp/com/shlcm/documents/jspCreateDocument1.jsp',
			onSubmit:function (){
			},
			success:function (data){
				//alert(data);
				if(data.indexOf("ERROR") != -1){
					$.messager.alert('提示',"创建失败");
				}else{
					var oid=data.split("__");
					$.messager.alert('提示',oid[0]);
					$('#cmTabs').tabs('close','创建文档');
					addTab1("","",oid[1],oid[2]);
				}
				hideProcessMsg("prince_process_ques");
			},
			onLoadError:function (){
				hideProcessMsg("prince_process_ques");
			}
		});
	}

	//创建一个新的tab 文档信息
	function addTab1(tabObj,tabId,oid,docName){
		var defaultTabId = "cmTabs";
		if(tabId){
			defaultTabId = tabId;
		}
		var tabDefault = {
			href:pageBaseUrl+"shmged/jsp/com/shlcm/documents/docInfo.jsp?oid="+oid,
			title:"文档:"+docName,
			selected: true,
			closable:true
		};
		var options ;
		if(tabObj){
		    var empty = {};
			options = $.extend(empty,tabDefault,tabObj);
		}else{
			options = tabDefault;
		}
		if($('#'+defaultTabId).tabs("exists",options.title)){
			$('#'+defaultTabId).tabs('select',options.title);
		}else{
		    $('#'+defaultTabId).tabs('add',options);
		}
//		alert(tab.outerHeight()+":"+tab.innerHeight());
//	    alert("index:"+index);
		//var oldHeight = p.panel('panel').outerHeight();  
		//setHeight();
	}
	initCreateQues1();
</script>
</body>

</html>


